using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Entity.Infrastructure;
using ShopPowerTemplate.Services.Properties;
using ShopPowerTemplate.Entities;

namespace ShopPowerTemplate.Services
{
    public class ShippingCostService : ShippingCostServiceBase, IShippingCostService
    {
		public ShippingCostService(IEntitiesDB entitiesDB) : base(entitiesDB) { }

		//Custom code here
        public decimal GetShippingCost(decimal weight) 
        {
            ShippingCost shippingCost = EntitiesDB.ShippingCostSet
                .FirstOrDefault(s => s.RangeMin >= weight && s.RangeMax <= weight);

            return shippingCost == null ? 0 : shippingCost.Cost;
        }
	}
}	

